const { ccclass, property, executionOrder } = cc._decorator;

import { menu } from '../../decorator';
import baseButtonTouch from './base/baseButtonTouch'

const BlockEvents = [
    'touchstart', 'touchmove', 'touchend', 'touchcancel',
    'mousedown', 'mousemove', 'mouseup',
    'mouseenter', 'mouseleave', 'mousewheel'
];

@ccclass
@menu(__filename)
@executionOrder(-9999)
export default class touchEnabled extends baseButtonTouch {

    _stopPropagation(event) {
        event.stopPropagation();
    }

    onEnable() {
        for (var i = 0; i < BlockEvents.length; i++) {
            this.target.on(BlockEvents[i], this._stopPropagation, this, true);
        }
    }

    onDisable() {
        for (var i = 0; i < BlockEvents.length; i++) {
            this.target.off(BlockEvents[i], this._stopPropagation, this);
        }
    }
}
